# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jaewon

import coin.exchange.binance.config as binance_config
import coin.exchange.binance.kr_rest.currency as binance_currency
import coin.exchange.okex.config as okex_config
import coin.exchange.okex.kr_rest.currency as okex_currency

binance_map = {}
for group, cur_list in binance_config.group_symbol.items():
  for cur in cur_list:
    try:
      cur = binance_currency.from_native_symbol(cur)
    except KeyError:
      print('ERROR: %s' % cur)
      continue
    assert cur not in binance_map
    binance_map[cur] = group

okex_map = {}
for group, cur_list in okex_config.group_symbol.items():
  for cur in cur_list:
    cur = okex_currency.from_native_symbol(cur)
    assert cur not in okex_map
    okex_map[cur] = group

common = {}
for cur in binance_map.keys():
  if cur in okex_map:
    common[cur] = (binance_map[cur], okex_map[cur])

for c in sorted(common.keys(), key=lambda x: (x.quote, x.base)):
  print('%10s %s %s' % (c, common[c][0], common[c][1]))
